package com.photoveil;

import java.util.HashMap;

import android.graphics.Typeface;
import android.widget.RelativeLayout;

@SuppressWarnings("serial")
public class TextPreference implements Preference {
	public static final HashMap<String, Integer> SIZE_MAP = new HashMap<String,Integer>() {{
		put("Small",15);
		put("Medium",25);
		put("Large",45);
	}};
	
	public static final HashMap<Integer, Integer> SIZE_POSITION_MAP = new HashMap<Integer,Integer>() {{
		put(15,0);
		put(25,1);
		put(45,2);
	}};
	
	public static final HashMap<String, Integer> COLOUR_MAP = new HashMap<String,Integer>() {{
		put("Black",0x000000);
		put("Blue",0x0000FF);
		put("Green",0x00FF00);
		put("Orange",0xFF8000);
		put("Purple",0x7600EC);
		put("Red",0xFF0000);
		put("White",0xFFFFFF);
		put("Yellow",0xFFFF00);
	}};
	
	public static final HashMap<Integer, Integer> COLOUR_POSITION_MAP = new HashMap<Integer,Integer>() {{
		put(0x000000, 0);
		put(0x0000FF, 1);
		put(0x00FF00, 2);
		put(0xFF8000, 3);
		put(0x7600EC, 4);
		put(0xFF0000, 5);
		put(0xFFFFFF, 6);
		put(0xFFFF00, 7);
	}};
	
	public static final HashMap<Integer, Typeface> FONT_POSITION_MAP = new HashMap<Integer, Typeface>() {{
		put(0, Typeface.DEFAULT);
		put(1, Typeface.MONOSPACE);
		put(2, Typeface.SANS_SERIF);
		put(3, Typeface.SERIF);
	}};
	
	public static final HashMap<Integer, Integer> STYLE_POSITION_MAP = new HashMap<Integer, Integer>() {{
		put(0, Typeface.NORMAL);
		put(1, Typeface.BOLD);
		put(2, Typeface.ITALIC);
		put(3, Typeface.BOLD_ITALIC);
	}};
	
	private String text;
	private int size;
	private int colour;
	private int position;
	private int font;
	private int style;
	
	public TextPreference(String text, String size, String colour, int position, int font, int style) {
		this.text = text;
		this.size = SIZE_MAP.get(size);
		this.colour = COLOUR_MAP.get(colour);
		this.position = position;
		this.font = font;
		this.style = style;
	}

	public String getText() {
		return text;
	}

	public int getSize() {
		return size;
	}
	
	public int getColour() {
		return colour;
	}
	
	public int getPosition() {
		return position;
	}
	
	public int getHorizontalPosition() {
		if (position % 3 == 0) {
			return RelativeLayout.ALIGN_LEFT;
		} else if (position % 3 == 1) {
			return RelativeLayout.CENTER_HORIZONTAL;
		} else {
			return RelativeLayout.ALIGN_RIGHT;
		}
	}
	
	public int getVerticalPosition() {
		if (position < 3) {
			return RelativeLayout.ALIGN_TOP;
		} else if (position >=3 && position < 6) {
			return RelativeLayout.CENTER_VERTICAL;
		} else {
			return RelativeLayout.ALIGN_BOTTOM;
		}
	}
	
	public int getFontPosition() {
		return font;
	}
	
	public Typeface getFontValue() {
		return FONT_POSITION_MAP.get(font);
	}
	
	public int getStylePosition() {
		return style;
	}
	
	public int getStyleValue() {
		return STYLE_POSITION_MAP.get(style);
	}
	
}
